package com.lzb.compressmaster;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import com.lzb.compressmaster.databinding.ActivityHomeBinding;
import com.lzb.compressmaster.fragment.CompressFragment;
import com.lzb.compressmaster.fragment.DecompressFragment;
import com.lzb.compressmaster.fragment.HomeFragment;
import com.lzb.compressmaster.fragment.MyFragment;

import java.util.ArrayList;
import java.util.List;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> {


    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment = new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class, R.id.llHome));
        listFragment.add(new FragmentViewBinder(CompressFragment.class, R.id.llCompress));
        listFragment.add(new FragmentViewBinder(DecompressFragment.class, R.id.llDecompress));
        listFragment.add(new FragmentViewBinder(MyFragment.class, R.id.llMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        int id = view.getId();
        if (id == R.id.llHome) {
            mDataBinding.ivHome.setImageResource(R.drawable.aawj);
            mDataBinding.tvHome.setTextColor(Color.parseColor("#246FFE"));
        } else if (id == R.id.llCompress) {
            mDataBinding.ivCompress.setImageResource(R.drawable.aays);
            mDataBinding.tvCompress.setTextColor(Color.parseColor("#246FFE"));
        } else if (id == R.id.llDecompress) {
            mDataBinding.ivDecompress.setImageResource(R.drawable.aajy);
            mDataBinding.tvDecompress.setTextColor(Color.parseColor("#246FFE"));
        } else if (id == R.id.llMy) {
            mDataBinding.ivMy.setImageResource(R.drawable.aagrzx);
            mDataBinding.tvMy.setTextColor(Color.parseColor("#246FFE"));
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flContainer;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.awj);
        mDataBinding.tvHome.setTextColor(Color.parseColor("#999999"));
        mDataBinding.ivCompress.setImageResource(R.drawable.ays);
        mDataBinding.tvCompress.setTextColor(Color.parseColor("#999999"));
        mDataBinding.ivDecompress.setImageResource(R.drawable.ajy);
        mDataBinding.tvDecompress.setTextColor(Color.parseColor("#999999"));
        mDataBinding.ivMy.setImageResource(R.drawable.agrzx);
        mDataBinding.tvMy.setTextColor(Color.parseColor("#999999"));
    }

}